package com.ice.app.system.job.controller;

import javax.servlet.http.HttpServletRequest;

import org.quartz.SchedulerException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iceframework.core.quartz.job.QuartzJob;
import com.iceframework.core.quartz.utils.ScheduleJobUtils;
import com.iceframework.core.utils.KeyUtils;
import com.iceframework.core.utils.MQUtils;

/**
 * 定时任务类
 * @author Palo
 *
 */
@Controller
@RequestMapping("/job")
public class JobController {

	@RequestMapping(value = "/add",method = RequestMethod.GET)
    public String add(String jobName,String triggerName,int seconds,HttpServletRequest request) throws SchedulerException{
		ScheduleJobUtils.addJob(jobName, triggerName, QuartzJob.class, seconds);
		return triggerName;
    }
	
	/**
	 * 
	 * @param request
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping(value = "/send/mq/test",method = RequestMethod.GET)
	@ResponseBody
	public String add(HttpServletRequest request) throws Exception{
		long currentTimeMillis = System.currentTimeMillis();
		for (int i= 0 ; i<10000 ; i++) {
			MQUtils.send("TEST", "测试消息"+KeyUtils.genUUID());	
		}
		long currentTimeMillis2 = System.currentTimeMillis();
		return ""+(currentTimeMillis2-currentTimeMillis);
		
	}
    
}
